package cn.tedu.csms.order.controller;

import cn.tedu.csms.base.response.JsonResult;
import cn.tedu.csms.employee.pojo.vo.EmployeeVO;
import cn.tedu.csms.order.pojo.dto.OrderQuery;
import cn.tedu.csms.order.pojo.dto.OrderSaveParam;
import cn.tedu.csms.order.service.IOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "订单板块")
@Slf4j
@RestController
@RequestMapping("/v1/order")
public class OrderController {

    @Autowired
    IOrderService orderService;

    @ApiOperation("查询订单接口")
    @GetMapping("/select")
    public JsonResult select(OrderQuery orderQuery){
        log.debug("查询订单:参数={}",orderQuery);
        List<EmployeeVO> employeeVOList = orderService.select(orderQuery);
        return JsonResult.ok(employeeVOList);
    }

    @ApiOperation("新增订单接口")
    @PostMapping("/save")
    public JsonResult save(OrderSaveParam orderSaveParam){
        log.debug("保存订单:参数={}",orderSaveParam);
        orderService.save(orderSaveParam);
        return JsonResult.ok();
    }

    @ApiOperation("删除订单接口")
    @PostMapping("/delete")
    public JsonResult delete(Long id){
        log.debug("删除订单:参数={}",id);
        orderService.delete(id);
        return JsonResult.ok();
    }
}
